package com.mrd.shiptask_shipowner.hwpush;

import android.app.Application;
import android.content.Context;

import com.loopj.android.http.AsyncHttpClient;
import com.mrd.shiptask_shipowner.activity.CrashHandler;

public class MyApplication extends Application {

	private static PustDemoActivity mPustTestActivity = null;
	private static Context mContext = null;

	public static AsyncHttpClient asyncHttpClient = new AsyncHttpClient();

	private static MyApplication mInstance;

	public static MyApplication instance() {
		return mInstance;
	}

	@Override
	public void onCreate() {
		super.onCreate();
		mInstance = this;
		CrashHandler crashHandler = CrashHandler.getInstance();
		crashHandler.init(getApplicationContext());
	}

	@Override
	public void onLowMemory() {
		super.onLowMemory();
		System.gc();
	}

	@Override
	public void onTerminate() {
		super.onTerminate();
		exit();
	}

	public void setContext(Context ctx) {
		mContext = ctx;
	}

	public Context getContext() {
		return mContext;
	}

	public void setMainActivity(PustDemoActivity activity) {
		mPustTestActivity = activity;
	}

	public PustDemoActivity getMainActivity() {
		return mPustTestActivity;
	}

	public void exit() {
		if (mPustTestActivity != null) {
			mPustTestActivity.finish();
		}
		System.exit(0);
	}

}
